export function formatDateWithTimezone(dateStr, timezoneOffset) {
  // 解析输入的日期字符串
  const dateParts = dateStr.split(' ');
  const datePart = dateParts[0].split('-');
  const timePart = dateParts[1].split(':');
  
  const year = parseInt(datePart[0], 10);
  const month = parseInt(datePart[1], 10) - 1; 
  const day = parseInt(datePart[2], 10);
  const hours = parseInt(timePart[0], 10);
  const minutes = parseInt(timePart[1], 10);
  const seconds = parseInt(timePart[2], 10) || 0;
  const date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));

  const formattedDate = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}T${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}${timezoneOffset}`;
  
  return formattedDate;
}

export function formatDateToCustomString(dateStr:string) {
  // 解析输入的日期字符串
  const [year, month, day] = dateStr.split('-').map(Number);
  
  // 创建一个Date对象
  const date = new Date(Date.UTC(year, month - 1, day)); // 月份是0基索引

  // 获取星期几（0为周日，6为周六）
  const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
  const dayOfWeek = weekdays[date.getUTCDay()];

  // 获取月份缩写
  const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
  const monthName = months[date.getUTCMonth()];

  const localDate = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));

  // 构造最终的字符串
  const formattedDate = `${dayOfWeek} ${monthName} ${day} ${year} ${localDate.toTimeString().split(' ')[0]} GMT+0800 (中国标准时间)`;

  return formattedDate;
}

